package org.blade.personal.manager.codeGen.concre;

import java.util.List;

import javax.annotation.Resource;
import javax.transaction.Transactional;

import org.blade.personal.dao.codegen.PackageDefinedDao;
import org.blade.personal.manager.codeGen.PackageDefinedManager;
import org.blade.personal.mode.codegen.PackageDefined;
import org.blade.personal.utils.treebuilder.TreeBuilder;
import org.springframework.stereotype.Service;

/**
 * 具体包定义管理者
 * @author ZGF
 *
 */
@Service

public class ConcrePackageDefinedManager implements PackageDefinedManager {

	private PackageDefinedDao packageDefinedDao;
	
	
	@Override
	@Transactional
	public void save(PackageDefined pkg) {
		// TODO Auto-generated method stub
		packageDefinedDao.add(pkg);
	}

	@Override
	@Transactional
	public void update(PackageDefined pkg) {
		// TODO Auto-generated method stub
		packageDefinedDao.update(pkg);
	}

	@Override
	@Transactional
	public int deleteById(String pkgid) {
		// TODO Auto-generated method stub
		
		PackageDefined packageDefined = new PackageDefined();
		packageDefined.setId(Long.parseLong(pkgid));
		return packageDefinedDao.delete(packageDefined);
	}

	@Override
	public int deleteByParentId(String parentId) {
		return packageDefinedDao.deleteByParentId(Long.parseLong(parentId));
	}

	@Override
	public List<PackageDefined> getPackage() {
		
		List list = packageDefinedDao.getAll();
		TreeBuilder treeBuilder = new TreeBuilder(0L);
		return treeBuilder.builder(list);
	}

}
